package views.report;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SpringLayout;
import uiframework.UIFrameWork;
import views.crm.CustomerReportView;
import views.inventory.StockReport;
import javax.swing.JLabel;
import controller.SalesReportController;
import controller.CustomerReportController;
import controller.StockReportController;
import java.awt.Dimension;
import java.awt.Font;

public class ReportView extends JPanel implements MouseListener 
{
	
	private JToolBar toolBar;
	private SpringLayout springLayout;
	
	public ReportView() 
	{
		springLayout = new SpringLayout();
		setLayout(springLayout);
		setSize(1050,550);
			
		toolBar=UIFrameWork.addToolBar(this, springLayout);
		String[] menunames={"SalesReport","CustomerReport","StockReport"};
		JLabel[] labels=UIFrameWork.setLeftMenu(menunames,toolBar, new Dimension(180, 40));
		Font f=new Font("MS Reference Sans Serif", Font.PLAIN, 13);
		UIFrameWork.styleLeftMenu(labels, f, null, null);		
	}
	
	
	private void stickForm(SpringLayout springLayout,JPanel panel)
	{
		springLayout.putConstraint(SpringLayout.SOUTH, panel, 0, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.HORIZONTAL_CENTER, panel, 0, SpringLayout.HORIZONTAL_CENTER, this);
		springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, panel, 0, SpringLayout.VERTICAL_CENTER, this);
		springLayout.putConstraint(SpringLayout.NORTH, panel, 0, SpringLayout.NORTH, this);
		add(panel);
		int x=this.getComponentCount();
		System.out.println(x);
		this.revalidate();
		this.repaint();
	}
	

	@Override
	public void mouseClicked(MouseEvent arg0) 
	{
		if(arg0.getSource() instanceof JLabel)
		{
			JLabel label=(JLabel) arg0.getSource();
			String labelTitle=label.getText();
			if(labelTitle.equals("SalesReport"))
			{
				SalesReportView view=new SalesReportView();
				UIFrameWork.setReportComponent(springLayout,view,this,2);
				SalesReportController contrl=new SalesReportController(view, null);
			}
			if(labelTitle.equals("CustomerReport"))
			{
				CustomerReportView view=new CustomerReportView();
				UIFrameWork.setReportComponent(springLayout,view,this,2);
				CustomerReportController custcontrl=new CustomerReportController(view, null);
			}
			if(labelTitle.equals("StockReport"))
			{
				StockReport view=new StockReport();
				UIFrameWork.setReportComponent(springLayout,view,this,2);
				StockReportController stockcontrl=new StockReportController(view, null);
			}
		}
	}

	@Override
	public void mouseEntered(MouseEvent arg0) 
	{
			
	}

	@Override
	public void mouseExited(MouseEvent arg0) 
	{
			
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
	      
	}
	
	@Override
	public void mouseReleased(MouseEvent arg0) 
	{
		
	}
	
}
